package com.template.mapper;

import com.template.dto.Meal;
import org.apache.ibatis.annotations.*;

@Mapper
public interface MealMapper {
    @Insert("insert into meal(crud,cssStyle,test,richTextEditor,note,forum) values (#{crud},#{cssStyle},#{test},#{richTextEditor},#{note},#{forum})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void add(Meal meal);

    @Insert("insert into mealanduser(userId,mealId) values (#{arg0},#{arg1})")
    void mealAndUser(Long userId,Long mealId);

    @Select("select mealId from mealanduser where userId=#{userId}")
    Long selectMealId(Long userId);

    @Select("select * from meal where id=#{id}")
    Meal selectMeal(Long id);

    @Update("update meal set crud=#{crud},cssStyle=#{cssStyle},test=#{test},richTextEditor=#{richTextEditor},home=#{home},community=#{community},note=#{note},forum=#{forum} where id=#{id}")
    void UpdateMealCount(Meal meal);

    @Delete("delete from meal where id=#{mealId}")
    void delById(Long mealId);
}
